<?php
declare(strict_types=1);

namespace App\Resource\RoomPK\PitPK;


use Carbon\Carbon;
use Illuminate\Http\Resources\Json\JsonResource;

class Resource extends JsonResource
{
    public function toArray($request)
    {
        return [
            "id" => $this->id,
            "room_id" => $this->room_id,
            "user_id" => $this->user_id,
            "red_pits" => is_null($this->red_pits) ? null : explode(",", $this->red_pits),
            "blue_pits" => is_null($this->blue_pits) ? null : explode(",", $this->blue_pits),
            "winner_camp" => $this->winner_camp,
            "red_score" => $this->red_score,
            "blue_score" => $this->blue_score,
            "red" => $this->red,
            "blue" => $this->blue,
            "status" => $this->status,
            "second" => $this->second,
            "start_at" => $this->start_at,
            "start_time" => Carbon::make($this->start_at)->timestamp,
            "end_at" => $this->end_at,
            "end_time" => Carbon::make($this->end_at)->timestamp,
        ];
    }
}